package org.demo.warehouse.controller;


import org.demo.warehouse.common.pojo.Goods;
import org.demo.warehouse.common.utils.R;
import org.demo.warehouse.service.IGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zgc
 * @since 202116
 */
@RestController
@RequestMapping("/goods")
public class GoodsController extends AbstractController<Goods> {
    @Autowired
    private IGoodsService goodsService;

    @Override
    protected void handleBeanBeforeSave(Goods param) {
        param.setUpdateTime(LocalDateTime.now());
    }

    @GetMapping("/checkItem")
    public R queryCheckItem() {
        return R.ok(service.lambdaQuery().select(Goods::getId, Goods::getName).list());
    }

    @GetMapping("/statistic")
    public R statistic(){
        return R.ok(goodsService.statistic());
    }
}

